 <?php

    #Ensure that the client has provided a value for "FirstAddressToSearch"
        
        #Setup variables
       

        
        #Connect to Database
        $con = mysqli_connect("localhost","root","", "test");
        
        #Check connection
        if (mysqli_connect_errno()) {
            echo 'Database connection error: ' . mysqli_connect_error();
            exit();
        }
	$userdetails=0;
        
        #Query the database to get the user details.
	if (isset($_POST["FirstAddressToSearch"]) && $_POST["FirstAddressToSearch"] != "")
	{
 	$firstname = $_POST["FirstAddressToSearch"];
        $userdetails = mysqli_query($con, "SELECT * FROM sample WHERE PropertyAddress = '$firstname' LIMIT 50");
	}
	if (isset($_POST["FirstZipToSearch"]) && $_POST["FirstZipToSearch"] != "")
	{
	$firstzip = $_POST["FirstZipToSearch"];
	$userdetails = mysqli_query($con, "SELECT * FROM sample WHERE PropertyZip = '$firstzip' LIMIT 50");
	}
	if (isset($_POST["FirstOwnerToSearch"]) && $_POST["FirstOwnerToSearch"] != "")
	{
 	$firstowner = $_POST["FirstOwnerToSearch"];
    $userdetails = mysqli_query($con, "SELECT * FROM sample WHERE PropertyOwner2 = '$firstowner' LIMIT 50");
	}

        #If no data was returned, check for any SQL errors
        if (!$userdetails) {
            echo 'Could not run query: ' . mysqli_error($con);
            exit;
}
        
	
	while($e=mysqli_fetch_assoc($userdetails))
	{
		$output[]=$e;
	}

        #Output the JSON data
        echo json_encode($userdetails); 
?> 